[#include "goodsAttr.html"]
<script type="text/javascript">
	//商品已选属性对象数组
	var selectedAttr = [];

	//加入购物车
	function addToCart(){
		var num = document.getElementById("number").value;
		$.ajax({
				url : __contextPath+"/addToCart.xhtml",
				type : "POST",
				data : {
					id:"${var_goodsid}",
					attr:selectedAttr.toString(),
					num:parseInt(num)
				},
				cache : false,
				dataType : 'text',
				success : function(data) {
					window.location.href=__contextPath+"/order/cartorder.xhtml";
				},
				error : function(jqXHR, textStatus, errorThrown) {
	           		alert(jqXHR.responseText);
				}
			});
	}
	function initPrice(){
		var num = document.getElementById("number").value;
		$.ajax({
				url : __contextPath+"/getTotalPrice.xhtml",
				type : "POST",
				data : {
					id:"${var_goodsid}",
					attr:selectedAttr.toString(),
					num:parseInt(num)
				},
				cache : false,
				dataType : 'text',
				success : function(data) {
					//var total = 0;
					//var tmp = parseInt(data*100);
					//total = tmp/100;
					data = Utils.subZeroAndDot(parseFloat(data).toFixed(2));
					document.getElementById("ECS_GOODS_AMOUNT").innerHTML = "￥"+data+"元"; 
				},
				error : function(jqXHR, textStatus, errorThrown) {
	           		alert(jqXHR.responseText);
				}
			});
	}
	function initAttr(){
		var jAttr=$("#priceArea input:checked");
		//清空属性
		selectedAttr = [];	
		jAttr.each(function(){
			selectedAttr.push(this.id);
		});
	}
	function init(){
		initAttr();
		initPrice();
	}
	window.onload = function (){
		init();
	}
</script>
[#-- 创建商品详细信息的自定义宏，参数：par_datalist 商品信息--]
[#macro ecs_goodsdetail data]
[#-- 读取商品属性数据的自定义标签，参数：par_goodsid--]
[@ecs_goodsattr par_goodsid = var_goodsid]
<div id="goodsInfo" class="clearfix">
	<div class="imgInfo">
		<a href="javascript:;" onclick=""> 
		[#-- 读取商品图片的自定义标签，参数：par_goodsid 商品ID。--]
		[@ecs_goodsimg par_goodsid = var_goodsid]
			<img src='${(var_virtualpath+var_productpath+var_goodsimginfo.bgpBig)!"${path}/images/no_picture.gif"}' alt="${data.bgiName!}" />
		[/@ecs_goodsimg]	
		</a>
		<div class="blank5"></div>
		<div class="clearfix">
			<div class="gallery">
				<div id="demo">
					<div id="demo1" style="float: left">
						<ul>
							<li>
								<a href="javascript:void(0);" target="_blank"><img
										src='${(var_virtualpath+var_productpath+var_goodsimginfo.bgpSmall)!"${path}/images/no_picture.gif"}'
										alt="${data.bgiName!}" class="B_blue" /> </a>
							</li>
						</ul>
					</div>
					<div id="demo2" style="display: inline; overflow: visible;"></div>
				</div>
			</div>
<!--			<span onmouseover="moveRight()" onmousedown="clickRight()"-->
<!--				onmouseup="moveRight()" onmouseout="scrollStop()" class="spanR"></span>-->
		</div>
		<div class="blank5"></div>
	</div>
	<div class="textInfo">
		<form action="" method="post"
			name="ECS_FORMBUY" id="ECS_FORMBUY">
			<div class="clearfix">
				<p class="f_l">
					${data.bgiName!}
				</p>
			</div>
			<ul>
				<li class="clearfix">
					<dd>
						<strong>商品货号：</strong>${data.bgiGsn!}
					</dd>
					<dd class="ddR">
						<strong>商品库存：</strong>${data.bgiNumber!} 台
					</dd>
				</li>
				<li class="clearfix">
					<dd>
						<strong>商品品牌：</strong><a href="${var_contextpath}/category.xhtml?brand=${data.bgiBrand}">${data.bgbName}</a>
					</dd>
					[#if data.bgiWeight??]
					<dd class="ddR">
						<strong>商品重量：</strong>${data.bgiWeight} 克
					</dd>
					[/#if]
				</li>
				<li class="clearfix">
					<dd>
						<strong>上架时间：</strong>${data.bgiOn!}
					</dd>
					<dd class="ddR">
						<strong>商品点击数：</strong>38
					</dd>
				</li>
				<li class="clearfix">
					<dd class="ddL">
						<strong>市场价格：</strong><font class="market">￥${data.bgiMarket!}元</font>
						<br />
						<strong>本店售价：</strong><font value="${data.bgiPrice!}" class="shop" id="ECS_SHOPPRICE">￥${data.bgiPrice?string('0.##')}元</font>
						<br />
					</dd>
					<dd style="width: 48%; padding-left: 7px;">
						<strong>用户评价：</strong>
						<img src="${path}/images/stars5.gif" alt="comment rank 5" />
					</dd>
				</li>
				<li class="clearfix">
					<dd>
						<strong>商品总价：</strong><font id="ECS_GOODS_AMOUNT" class="shop"></font>
					</dd>
					<dd class="ddR">
					</dd>
				</li>
				<li class="clearfix">
					<dd>
						<strong>购买数量：</strong>
						<input name="number" type="text" id="number" value="1"
							size="4" onblur="changePrice()"
							style="border: 1px solid #ccc;" />
					</dd>
					<dd class="ddR">
						<strong>购买此商品可使用：</strong><font class="f4">2200 积分</font>
					</dd>
				</li>
				
					[#-- 创建商品属性信息的自定义宏，参数：par_datalist 属性列表，var_isprice 是否价格属性--]
					[@ecs_goodsallattr par_datalist = var_goodsattr var_isprice = true /]			
				
				<li class="padd">
					<a href="javascript:addToCart('${data.bgiId}')"><img
							src="${path}/images/bnt_cat.gif" /> </a>
					<a href="javascript:collect('${data.bgiId}')"><img
							src="${path}/images/bnt_colles.gif" /> </a>
<!--					<a href="user.php?act=affiliate&goodsid=9"><img-->
<!--							src="${path}/images/bnt_recommend.gif" /> </a>-->
				</li>
			</ul>
		</form>
	</div>
</div>
<div class="blank"></div>
	<div class="box">
		<div class="box_1">
			<h3 style="padding: 0 5px;">
				<div id="com_b" class="history clearfix">
					<h2>
						商品描述：
					</h2>
					<h2 class="h2bg">
						商品属性
					</h2>
				</div>
			</h3>
			<div id="com_v" class="boxCenterList RelaArticle"></div>
			<div id="com_h">
				<blockquote>
				[#if data.bgiDetail==""]
					暂无
				[#else]
					${data.bgiDetail}
				[/#if]
				</blockquote>
					[#-- 创建商品属性信息的自定义宏，参数：par_datalist 属性列表，var_isprice 是否价格属性--]
					[@ecs_goodsallattr par_datalist = var_goodsattr  var_isprice = false/]	
			</div>
		</div>
	</div>
[/@ecs_goodsattr]
[/#macro]